<template>
    <div id="fireManagement">
        <div style="height: 100%;">
            <div class="trees">
                <div class="tree_title">
                    <h3 class="tree_title_h3">机构列表</h3>
                </div>
                <div class="tree_body">
                    <Tree :data="baseData" @on-select-change="clickTree"></Tree>
                </div>
            </div>
            <div class="body_right">
                <div class="header-right">
                    车辆信息管理
                </div>
                <div class="btn_group">
                    <Select clearable v-model="truckTypeText" filterable size="small" placeholder="车辆类型" style="width: 15rem;">
                        <Option v-for="item in truckTypeData" :value="item.value" :key="item.value">{{item.value}}
                        </Option>
                    </Select>
                    <Input v-model="trunckModel" placeholder="车辆型号" size="small" style="width: 15rem;"/>
                    <Button type="primary" icon="ios-search" size="small" @click="search">查询</Button>
                    <Button type="ghost" icon="ios-trash-outline" size="small" style="float:right;margin-right: 6px" @click="batchDele">
                        批量删除
                    </Button>
                    <Button type="ghost" icon="ios-plus-empty" size="small" style="float:right;margin-right: 6px" @click="add">新增
                    </Button>
                </div>
                <div class="tableWidth">
                    <Table border :columns="columns7" :data="data6" stripe @on-selection-change="compileSelect"></Table>
                </div>
                <!--车辆信息管理表-->
                <Modal v-model="modal5" title="消防车辆信息" width="800" :closable="false" :mask-closable="false">
                    <Form action="post" ref="formValidate" :model="formValidate" :rules="ruleValidate"
                          :label-width="110" style="margin-right: 20px">
                        <Form-item label="所属单位" prop="departmentName">
                            <p>{{formValidate.departmentName}}</p>
                        </Form-item>
                        <Row>
                            <Col span="12">
                            <Form-item label="车辆名称" prop="truckName">
                                <Input v-model="formValidate.truckName" placeholder="请输入车辆名称"></Input>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="车牌号" prop="licencePlateNumber">
                                <Input v-model="formValidate.licencePlateNumber" placeholder="请输入车牌号"></Input>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="车辆类型" prop="truckTypeName">
                                <Select clearable v-model="formValidate.truckTypeName" placeholder="请选择车辆类型">
                                    <Option v-for="item in truckTypeData" :value="item.value" :key="item.value">
                                        {{item.value}}
                                    </Option>
                                </Select>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="车辆型号" prop="truckModel">
                                <Input v-model="formValidate.truckModel" placeholder="请输入车辆型号"></Input>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="投用时间" prop="attendTime">
                                <Date-picker type="date" placeholder="选择日期和时间" v-model="formValidate.attendTime" @on-change="showtime"></Date-picker>
                            </Form-item>
                            </Col>
                          <Col span="12">
                          <Form-item label="生产厂商" prop="manufacturer">
                            <Input v-model="formValidate.manufacturer" placeholder="生产厂家"></Input>
                          </Form-item>
                          </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="生产日期" prop="productionDate">
                                <Date-picker type="date" placeholder="生产日期" v-model="formValidate.productionDate" @on-change="productionDateChange"></Date-picker>
                            </Form-item>
                            </Col>
                          <Col span="12">
                          <Form-item label="消防炮型号" prop="fireMonitorType">
                            <Input v-model="formValidate.fireMonitorType" placeholder="请输入消防炮型号"></Input>
                          </Form-item>
                          </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="泡沫原液容量(L)" prop="foamCapacity">
                                <Input-number :min="0" v-model="formValidate.foamCapacity" placeholder="请输入泡沫原液容量" style="width: 265px"></Input-number>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="干粉量(kg)" prop="naxAmount">
                                <Input-number :min="0" v-model="formValidate.naxAmount" placeholder="请输入干粉量" style="width: 265px"></Input-number>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="水罐容量(L)" prop="waterTankCapacity">
                                <Input-number :min="0" v-model="formValidate.waterTankCapacity" placeholder="请输入水罐容量" style="width: 265px"></Input-number>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="消防系统量(kg)" prop="fireSystemAmount">
                                <Input-number :min="0" v-model="formValidate.fireSystemAmount" placeholder="请输入消防系统量" style="width: 265px"></Input-number>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="扬程(m)" prop="liftParameter">
                                <Input-number :min="0" v-model="formValidate.liftParameter" placeholder="请输入扬程" style="width: 265px"></Input-number>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="最大吸水高度(m)" prop="maxSuctionHeight">
                                <Input-number :min="0" v-model="formValidate.maxSuctionHeight" placeholder="请输入消防泵最大吸水高度" style="width: 265px"></Input-number>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                          <Col span="12">
                          <Form-item label="使用年限" prop="durableYears">
                            <Input-number :min="0" v-model="formValidate.durableYears" placeholder="请输入使用年限" style="width: 265px"></Input-number>
                          </Form-item>
                          </Col>
                            <Col span="12">
                            <Form-item label="消防炮流量(L/S)" prop="fireMonitorAmount">
                                <Input-number :min="0" v-model="formValidate.fireMonitorAmount" placeholder="请输入消防炮流量" style="width: 265px"></Input-number>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="消防炮射程(m)" prop="fireMonitorRange">
                                <Input-number :min="0" v-model="formValidate.fireMonitorRange" placeholder="请输入消防炮射程" style="width: 265px"></Input-number>
                            </Form-item>
                            </Col>
                            <Col span="12">
                            <Form-item label="居高高度(m)" prop="altitude">
                                <Input-number :min="0" v-model="formValidate.altitude" placeholder="请输入居高高度" style="width: 265px"></Input-number>
                            </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="12">
                            <Form-item label="泵浦类型" prop="pumpType">
                                <Input v-model="formValidate.pumpType" placeholder="请输入泵浦类型"></Input>
                            </Form-item>
                            </Col>
                        </Row>
                        <Form-item label="功能说明" prop="functionDescription">
                            <Input v-model="formValidate.functionDescription" type="textarea" :autosize="true"
                                   placeholder="请输入...(200字以内)"></Input>
                        </Form-item>
                        <Form-item label="车辆维护记录" prop="serviceRecord">
                            <Input v-model="formValidate.serviceRecord" type="textarea" :autosize="true"
                                   placeholder="请输入...(200字以内)"></Input>
                        </Form-item>
                    </Form>
                    <div slot="footer">
                        <Button type="ghost" size="small" @click="cancelFrom">取消</Button>
                        <Button type="primary" size="small" @click="handleSubmit('formValidate')">提交</Button>
                    </div>
                </Modal>
                <div class="page_container">
                    <Page :current="currentPage" :total="totalCount" size="small" simple class="page_btn"
                          @on-change="changePage"></Page>
                    <P class="page_text">共{{totalCount}}条</P>
                </div>
                <!--随车器材管理表-->
                <Modal v-model="equipmentManagement" title="随车器材管理" width="800" :closable="false" :mask-closable="false">
                    <Form action="post" ref="formValidate1" :model="formValidate1" :rules="ruleValidate1"
                          :label-width="90">
                        <Form-item label="器材名称" prop="equipmentName">
                            <Input v-model="formValidate1.equipmentName" placeholder="器材名称"></Input>
                        </Form-item>
                        <Form-item label="器材型号" prop="type">
                            <Input v-model="formValidate1.type" placeholder="器材型号"></Input>
                        </Form-item>
                        <Form-item label="器材数量" prop="amount">
                            <Input-number type="text"  @on-change="equipmentNumber" :min="0" v-model="formValidate1.amount" placeholder="器材数量"  ></Input-number>
                        </Form-item>
                        <Form-item label="装车日期" prop="accessoryTime">
                            <Date-picker type="date" placeholder="装车日期" v-model="formValidate1.accessoryTime" @on-change="showCreateTime"></Date-picker>
                        </Form-item>
                        <Form-item label="用途说明" prop="purpose">
                            <Input v-model="formValidate1.purpose" type="textarea" :autosize="true" placeholder="请输入...(200字以内)"></Input>
                        </Form-item>
                    </Form>
                    <div slot="footer" style="margin-bottom:10px;">
                        <Button type="ghost" size="small" @click="cancelFrom1">取消</Button>
                        <Button type="primary" size="small" @click="handleSubmit1('formValidate1')">保存</Button>
                    </div>
                    <div class="tableWidth" slot="footer">
                        <Table border :columns="equipmentManagementTable" :data="accessoryEquipment" stripe @on-selection-change="compileSelectEq"></Table>
                    </div>
                    <div class="page_container" slot="footer">
                        <Page :current="currentPage1" :total="totalCount1" size="small" simple class="page_btn" @on-change="changePage1"></Page>
                        <P class="page_text">共{{totalCount1}}条</P>
                    </div>
                </Modal>
                <!--随车人员显示管理表-->
                <Modal v-model="personnelManagement" title="随车人员管理" width="800" :closable="false" :mask-closable="false">
                    <div class="tableWidth">
                        <Table border :columns="personnelManagementTable" :data="personnelManagementDatas" stripe></Table>
                    </div>
                    <div class="page_container" slot="footer">
                        <!--<Page :current="currentPage2" :total="totalCount2" size="small" simple class="page_btn"-->
                              <!--@on-change="changePage2"></Page>-->
                        <P class="page_text">共{{personnelManagementDatas.length}}人</P>
                    </div>
                    <div slot="footer">
                      <Button type="ghost" size="small" @click="cancelFrom2">取消</Button>
                        <Button type="primary" size="small" @click="addPersonal">添加人员</Button>
                    </div>
                </Modal>
                <!--选择人员来源管理表-->
                <Modal v-model="personnelManagementData" title="随车人员添加表" width="800" id="modal">
                    <div class="tableWidth">
                        <Table border :columns="personnelManagementTableData" :data="personnelManagementTableDatas"
                               stripe @on-selection-change="surePersonal"></Table>
                    </div>
                    <div class="page_container" slot="footer">
                        <Page :current="currentPage3" :total="totalCount3" size="small" simple class="page_btn"
                              @on-change="changePage3"></Page>
                        <P class="page_text">共{{totalCount3}}条</P>
                    </div>
                    <div slot="footer">
                        <Button type="ghost" size="small" @click="backPersonal">返回</Button>
                        <Button type="primary" size="small" @click="diaojiekou">添加选中</Button>
                    </div>
                </Modal>
            </div>
        </div>
    </div>
</template>
<script type="text/javascript">
    var ezjsUtil = Vue.ezjsUtil;
    var apiConstants = ezjsUtil.constants.api;
    export default {
        data() {
          const validateAttendTime = (rule, value, callback) => {
            if (value === '') {
              callback(new Error('请选择日期'));
            }else {
              callback();
            }
          };
          const validateProductionDate = (rule, value, callback) => {
            if (value === '') {
              callback(new Error('请选择日期'));
            }else {
              callback();
            }
          };
            return {
                departmentCode:CURRENT_LEADER.departmentCode,  //登录人员code值
                valueLen:'', //点击树获得的code值
                equipmentFollwCar: '', //随车器材记录主表ID
                carId: null,
                staffIds: '',
                selectionPersonal: [],
                trunckModel: '', //车辆型号
                truckTypeText: '',
                truckTypeData: [],
                idss: "",   //批量删除项（各项ids值-以字符串形式串联起来，逗号分割）
                eqidss: "",
                qeidss: "",
                search_code: '', //按照物资名称搜索
                currentPage: 1, //主页面当前页
                totalCount: 0,  //主页面总条数
                currentPage1: 1, //随车器材页面当前页
                totalCount1: 0,  //随车页面总条数
                currentPage2: 1, //随车人员显示页面当前页
                totalCount2: 0,  //随车人员显示页面总条数
                currentPage3: 1, //随车人员显示页面当前页
                totalCount3: 0,  //随车人员显示页面总条数
                /*  表头开始*/
                columns7: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '所属单位',
                        align: 'center',
                        key: 'departmentName',
                    },
                    {
                        title: '车辆名称',
                        key: 'truckName',
                        align: 'center'

                    },
                    {
                        title: '车辆类型',
                        key: 'truckTypeName',
                        align: 'center'
                    },
                    {
                        title: '车牌号',
                        key: 'licencePlateNumber',
                        align: 'center'
                    },
                    {
                        title: '车辆型号',
                        key: 'truckModel',
                        align: 'center'
                    },
                    {
                        title: '投用时间',
                        key: 'attendTime',
                        align: 'center',
/*                        render: function (h, params) {
                            var newTime = new Date(params.row.attendTime);
                            var Y = newTime.getFullYear();
                            var M = newTime.getMonth() + 1;
                            var D = newTime.getDate();
                            var H = newTime.getHours();
                            var m = newTime.getMinutes();
                            var s = newTime.getSeconds();
                            var time = Y + "-" + M + "-" + D;
                            return h('div', time);
                        }*/
                    },
                    {
                        title: '随车器材',
                        key: 'action',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    on: {
                                        click: () => {
                                            this.equipmentFollwCar = params.row.id;
                                            this.formValidate1.fireTruckInformationId = this.equipmentFollwCar;
                                            this.fireTruckInformation_flipListForEquipment();
                                            this.equipmentManagement = true;
                                        }
                                    }
                                }, '编辑')
                            ]);
                        }
                    },
                    {
                        title: '随车人员',
                        key: 'action',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    on: {
                                        click: () => {
                                            this.show2(params.index);
                                        }
                                    }
                                }, '编辑')
                            ]);
                        }
                    },
                    {
                        title: '操作',
                        key: 'action',
                        align: 'center',
                        width: 150,
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.carInfoEdit(params.row)
                                        }
                                    }
                                }, '修改'),
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    on: {
                                        click: () => {
                                            this.carRemoveInfo(params.row.id)
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    },
                ],
                /* 随车器材管理表结构开始*/
                equipmentManagementTable: [
                    {
                        title: '器材名称',
                        key: 'equipmentName',
                        align: 'center'
                    },
                    {
                        title: '器材型号',
                        key: 'type',
                        align: 'center'
                    },
                    {
                        title: '器材数量',
                        key: 'amount',
                        align: 'center'
                    },
                    {
                        title: '装车日期',
                        key: 'accessoryTime',
                        align: 'center',
/*                        render: function (h, params) {
                            var newTime = new Date(params.row.accessoryTime);
                            var Y = newTime.getFullYear();
                            var M = newTime.getMonth() + 1;
                            var D = newTime.getDate();
                            var H = newTime.getHours();
                            var m = newTime.getMinutes();
                            var s = newTime.getSeconds();
                            var time = Y + "-" + M + "-" + D;
                            return h('div', time);
                        }*/
                    },
                    {
                        title: '用途说明',
                        key: 'purpose',
                        align: 'center'
                    },
                    {
                        title: '操作',
                        key: 'action',
                        align: 'center',
                        width: 150,
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.modifyEquipment(params.row)
                                        }
                                    }
                                }, '修改'),
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    on: {
                                        click: () => {
                                            this.deleEquipment(params.row.id)
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    },

                ],
                /* 随车人员表结构*/
                personnelManagementTable: [
                    {
                        type: 'index',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '所属单位',
                        key: 'departmentName',
                        align: 'center'
                    },
                    {
                        title: '姓名',
                        key: 'name',
                        align: 'center'
                    },
                    {
                        title: '职务',
                        key: 'business',
                        align: 'center'
                    },
                    {
                        title: '操作',
                        key: 'action',
                        align: 'center',
                        width: 150,
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    on: {
                                        click: () => {
                                            this.delePersonal(params.row.id)
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    },

                ],
                personnelManagementTableData: [
                    {
                        type: 'selection',
                        key: 'action',
                        align: 'center',
                        width: 60,
                    },
                    {
                        title: '姓名',
                        key: 'name',
                        align: 'center'
                    },
                    {
                        title: '职务',
                        key: 'businessName',
                        align: 'center'
                    },
                    {
                        title: '所在单位',
                        key: 'departmentName',
                        align: 'center'
                    },
                ],
                /*表头结束*/
                /* 表格数据显示区域*/
                data6: [],
                accessoryEquipment: [],
                personnelManagementTableDatas: [],
                personnelManagementDatas: [],
                /* 树结构*/
                baseData: [],
                /* 全局变量*/
                modal5: false,
                equipmentManagement: false,
                personnelManagement: false,
                personnelManagementData: false,
                formValidate: { //表单验证
                    id: '',
                    truckName: '',                       //1   车辆名称
                    departmentNameCopy:'',                       //保存所属单位
                    licencePlateNumber: '',              //2   车牌号
                    truckTypeId: '',
                    truckTypeName: '',                   //3   车辆类型
                    truckModel: '',                       //4   车辆型号
                    attendTime: '',                       //5   投用时间
                    durableYears:0,                     //6   使用年限
                    foamCapacity: 0,                     //7   泡沫原液容量
                    naxAmount: 0,                        //8   干粉量
                    waterTankCapacity:0,                //9   水罐容量
                    fireMonitorAmount:0,              //10  消防炮流量
                    liftParameter: 0,                    //11  扬程
                    maxSuctionHeight: 0,                 //12  消防泵最大吸水高度
                    fireMonitorType: '',                  //13  消防炮型号
                    fireMonitorRange: 0,                 //15  消防炮射程
                    altitude:0,                         //16  居高高度
                    functionDescription: '',              //17  功能说明
                    serviceRecord: '',                     //18  车辆维护记录
                    equipmentName: '',                     //19   器材名称
                    type: '',                              //20   类型
                    purpose: '',                           //21    用途说明
                    amount: 0,                            //22    数量
                    departmentName: '',                    //23    所在单位
                    name: '',                              //24    职工姓名
                    businessName: '',                      //25    职务
                    staffList: '',                         //26    人员列表
                    departmentCode: '',
                    manufacturer: '',
                    productionDate: '',
                    pumpType: '',
                    fireSystemAmount:0,                     //消防系统量
                },
                ruleValidate: {
                    truckName: [
                        {required: true, message: '车辆名称不能为空', trigger: 'blur'}
                    ],
                    licencePlateNumber: [
                        {required: true, message: '车牌号不能为空', trigger: 'blur'}
                    ],
                    truckTypeName: [
                        {required: true, message: '车辆类型不能为空', trigger: 'change'},
                    ],
                    truckModel: [
                        {required: true, message: '车辆型号不能为空', trigger: 'blur'}
                    ],
                    attendTime: [
                        {required: true, validator: validateAttendTime, trigger: 'change'}
                    ],
                    productionDate: [
                        {required: true, validator: validateProductionDate, trigger: 'change'}
                    ],
                    departmentName: [
                        {required: true, message: '所属单位不能为空', trigger: 'blur'}
                    ],
                    functionDescription: [
                        {type:'string',max:200, message: '输入200字以内', trigger: 'blur'}
                    ],
                    serviceRecord: [
                        {type:'string',max:200, message: '输入200字以内', trigger: 'blur'}
                    ],
                    foamCapacity: [
                      {required: true,type:'number', message: '泡沫原液容量不能为空', trigger: 'change'}
                    ],
                    naxAmount: [
                      {required: true,type:'number', message: '干粉量不能为空', trigger: 'change'}
                    ],
                    waterTankCapacity: [
                      {required: true,type:'number', message: '水罐容量不能为空', trigger: 'change'}
                    ],
                     fireSystemAmount: [
                      {required: true,type:'number', message: '消防系统量不能为空', trigger: 'change'}
                    ],
                     liftParameter: [
                      {required: true,type:'number', message: '扬程不能为空', trigger: 'change'}
                    ],
                     maxSuctionHeight: [
                      {required: true,type:'number', message: '最大吸水高度不能为空', trigger: 'change'}
                    ],
                    durableYears: [
                      {required: true,type:'number', message: '使用年限不能为空', trigger: 'change'}
                    ],
                    fireMonitorAmount: [
                      {required: true,type:'number', message: '消防炮流量不能为空', trigger: 'change'}
                    ],
                    fireMonitorRange: [
                      {required: true,type:'number', message: '消防炮射程不能为空', trigger: 'change'}
                    ],
                    altitude: [
                      {required: true,type:'number', message: '居高高度不能为空', trigger: 'change'}
                    ],
                },
                formValidate1: {
                    id: '',
                    fireTruckInformationId: '',
                    equipmentName: '',
                    type: '',
                    purpose: '',
                    amount: 0,
                    accessoryTime: '',
                },
                ruleValidate1: {
                    equipmentName: [
                        {required: true, message: '请输入器材名称', trigger: 'blur'}
                    ],
                    type: [
                        {required: true, message: '请输入器材型号', trigger: 'blur'}
                    ],
                    amount: [
                        {required: true,type:'number', message: '器材数量不能为空', trigger: 'change'}
                    ],
                    accessoryTime: [
                      {required: true, message: '装车日期不能为空', trigger: 'change'}
                    ],
                    purpose: [
                        {type:'string',max:200, message: '输入200字以内', trigger: 'blur'}
                    ],
                },
            }
        },
        /* 在实例初始化之后，数据观测(data observer) 和 event/watcher 事件配置之前被调用。*/
        created() {
            this.dictionary_flipList();
            this.organization_flipList();
            this.fireManagement_flipList();
//            this.staffManagement_flipList();
        },
        /*在挂载开始之前被调用：相关的 render 函数首次被调用。*/
        mounted: function () {

        },
        methods: {
          equipmentNumber(value){
            if(parseInt(value)==value){
              this.formValidate1.amount = value;
            }else{
              this.formValidate1.amount = 0;
            }
          },
            add() {
                if (this.formValidate.departmentName != '') {
                    this.formValidate.id = "";
                    this.modal5 = true;
                }else if( this.valueLen <= 0){
                    this.$Modal.info({
                      content: '请在机构列表选择机构单位！'
                    });
                }else{
                  this.$Message.error('权限不够，无法新增，请联系管理员！');
                }
            },
            //日期格式转换
            dateformatting(dateval) {
                var newTime = new Date(dateval);
                var yyyy = newTime.getFullYear();
                var MM = newTime.getMonth() + 1;
                var dd = newTime.getDate();
                var hh = newTime.getHours();
                var mm = newTime.getMinutes();
                var ss = newTime.getSeconds();
                var time = yyyy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
                return time
            },
            carInfoEdit(value) { //edit
                this.formValidate.id = value.id;
                this.formValidate.truckName = value.truckName;
                this.formValidate.licencePlateNumber = value.licencePlateNumber;
                this.formValidate.truckModel = value.truckModel;
                this.formValidate.attendTime = value.attendTime;
                this.formValidate.durableYears = value.durableYears;
                this.formValidate.foamCapacity = value.foamCapacity;
                this.formValidate.naxAmount = value.naxAmount;
                this.formValidate.waterTankCapacity = value.waterTankCapacity;
                this.formValidate.fireSystemAmount = value.fireSystemAmount;
                this.formValidate.fireMonitorAmount = value.fireMonitorAmount;
                this.formValidate.liftParameter = value.liftParameter;
                this.formValidate.maxSuctionHeight = value.maxSuctionHeight;
                this.formValidate.fireMonitorType = value.fireMonitorType;
                this.formValidate.fireMonitorRange = value.fireMonitorRange;
                this.formValidate.altitude = value.altitude;
                this.formValidate.departmentName = value.departmentName;
                this.formValidate.departmentCode = value.departmentCode;
                this.formValidate.truckTypeName = value.truckTypeName;
                this.formValidate.manufacturer= value.manufacturer;
                this.formValidate.productionDate= value.productionDate;
                this.formValidate.pumpType= value.pumpType;
                this.formValidate.functionDescription= value.functionDescription;
                this.formValidate.serviceRecord= value.serviceRecord;
                this.modal5 = true;
            },
            showtime(data) {  //改变时，将日期值赋值
                this.formValidate.attendTime = data;
            },
            productionDateChange(data) {  //改变时，将日期值赋值
                this.formValidate.productionDate = data;
            },
            showCreateTime(data) {  //改变时，将日期值赋值
                this.formValidate1.accessoryTime = data;
            },

            cancelFrom() {  //单击取消重置并关闭模态框
                this.handleReset('formValidate');
                this.formValidate.departmentName=this.formValidate.departmentNameCopy;
                this.modal5 = false;
              /*  this.formValidate.departmentCode = '';*/
                this.formValidate.departmentCode =this.search_code;
            },
            cancelFrom1() {  //单击取消重置并关闭模态框--随车器材弹出框
                this.formValidate1.id='';
                this.handleReset('formValidate1');
                this.equipmentManagement = false;
                this.currentPage1 = 1;
            },
          cancelFrom2() {  //单击取消重置并关闭模态框--随车人员显示弹出框
                this.personnelManagement = false;
            },

            show2(index) {
                this.carId = this.data6[index].id;
                this.fireTruckInformation_flipListForCrew();
                this.personnelManagement = true;
            },
            /*  分页*/
            changePage(page) {     //主页面分页展示
                this.currentPage = page;
                this.fireManagement_flipList();
            },
            changePage1(page1) {     //随车器材页面分页展示
                this.currentPage1 = page1;
                this.fireTruckInformation_flipListForEquipment();
            },
            changePage2(page2) {     //随车人员展示页面分页展示
                this.currentPage2 = page2;
                this.fireTruckInformation_flipListForCrew();
            },
            changePage3(page3) {     //随车人员添加表页面分页展示
                this.currentPage3 = page3;
                this.staffManagement_flipList();
            },
            fireManagement_flipList() { //显示 查询
                var _this = this;
                ezjsUtil.request(apiConstants.fireTruckInformation_flipList,
                    {
                        truckTypeName: _this.truckTypeText,
                        truckModel: _this.trunckModel,
                        pageNo: _this.currentPage,
                        departmentCode: _this.formValidate.departmentCode,
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.data6 = data.listInfo;
                        _this.totalCount = data.flipInfo.totalCount;
                    }
                )
            },
            fireTruckInformation_edit() { //新增车辆信息
                var _this = this;
                ezjsUtil.request(apiConstants.fireTruckInformation_edit,
                    {
                        id: _this.formValidate.id,
                        departmentCode: _this.formValidate.departmentCode,
                        departmentName: _this.formValidate.departmentName,
                        truckName: _this.formValidate.truckName,
                        truckTypeName: _this.formValidate.truckTypeName,
                        truckTypeId: _this.formValidate.truckTypeId,
                        truckModel: _this.formValidate.truckModel,
                        attendTime: _this.formValidate.attendTime,
                        foamCapacity: _this.formValidate.foamCapacity,
                        waterTankCapacity: _this.formValidate.waterTankCapacity,
                        liftParameter: _this.formValidate.liftParameter,
                        fireMonitorType: _this.formValidate.fireMonitorType,
                        licencePlateNumber: _this.formValidate.licencePlateNumber,
                        durableYears: _this.formValidate.durableYears,
                        naxAmount: _this.formValidate.naxAmount,
                        fireSystemAmount: _this.formValidate.fireSystemAmount,
                        fireMonitorAmount: _this.formValidate.fireMonitorAmount,
                        maxSuctionHeight: _this.formValidate.maxSuctionHeight,
                        altitude: _this.formValidate.altitude,
                        fireMonitorRange: _this.formValidate.fireMonitorRange,
                        functionDescription: _this.formValidate.functionDescription,
                        serviceRecord: _this.formValidate.serviceRecord,
                        manufacturer: _this.formValidate.manufacturer,
                        productionDate: _this.formValidate.productionDate,
                        pumpType: _this.formValidate.pumpType,
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.formValidate.departmentName="";
                        _this.formValidate.departmentCode="";
                        _this.formValidate.departmentNameCopy="";
                        _this.fireManagement_flipList();
                        _this.valueLen = '';
                        _this.organization_flipList();



                    }
                )
            },
            //删除
            compileSelect(selection, row) {   //表格选择
                var ids = "";
                for (var i = 0; i < selection.length; i++) {
                    ids = selection[i].id + "," + ids;    //逗号分隔
                }
                this.idss = ids;
            },
            carRemoveInfo(value) {  //单个删除
                this.idss = value;
                this.fireTruckInformation_removeByIds();
            },
            batchDele() { //批量删除
              if(this.idss !==""){
                this.fireTruckInformation_removeByIds(); //调用删除接口
              } else{
                  this.$Message.error('请选择删除项!');
              }

            },
            fireTruckInformation_removeByIds() { //删除车辆信息
                var _this = this;
                ezjsUtil.request(apiConstants.fireTruckInformation_removeByIds,
                    {
                        ids: _this.idss   //将选中项的的ids给ids（字符串形式，逗号分隔）
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.idss='';
                        _this.fireManagement_flipList();
                    },
                )
            },
            search() { //查询
                this.currentPage=1;
                this.fireManagement_flipList();  //调用显示接口
            },
            handleSubmit(name) {  //表单验证
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.fireTruckInformation_edit();  //调用编辑接口
                        this.$Message.success('提交成功!');
                        this.modal5 = false;               //关闭模态框
                        this.handleReset('formValidate');
                    } else {
                        this.$Message.error('表单验证失败!');
                    }
                })
            },
            handleSubmit1(name) {  //表单验证
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.fireTruckInformation_editForEquipment();
                        this.$Message.success('提交成功!');
                        this.handleReset('formValidate1');
                        this.formValidate1.id='';
                    } else {
                        this.$Message.error('表单验证失败!');
                    }
                })
            },
            handleReset(name) {  //重置
                this.$refs[name].resetFields();
            },
            /*随车器材增删改*/
            fireTruckInformation_flipListForEquipment() { //显示 查询
                var _this = this;
                ezjsUtil.request(apiConstants.fireTruckInformation_flipListForEquipment,
                    {
                        fireTruckInformationId: _this.equipmentFollwCar,
                        pageNo: _this.currentPage1
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.accessoryEquipment = data.listInfo;
                        _this.totalCount1 = data.flipInfo.totalCount;
                    }
                )
            },
            fireTruckInformation_editForEquipment() { //新增车辆信息
                var _this = this;
                ezjsUtil.request(apiConstants.fireTruckInformation_editForEquipment,
                    {
                        id: _this.formValidate1.id,
                        fireTruckInformationId: _this.formValidate1.fireTruckInformationId,
                        equipmentName: _this.formValidate1.equipmentName,
                        type: _this.formValidate1.type,
                        purpose: _this.formValidate1.purpose,
                        amount: _this.formValidate1.amount,
                        accessoryTime: _this.formValidate1.accessoryTime,
                        departmentCode: _this.formValidate1.departmentCode,
                        departmentName: _this.formValidate1.departmentName,
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
//            _this.handleReset('formValidate1');
                        _this.fireTruckInformation_flipListForEquipment();
                    }
                )
            },
            modifyEquipment(value) { //edit
                this.formValidate1.id = value.id;
                this.formValidate1.fireTruckInformationId = value.fireTruckInformationId;
                this.formValidate1.equipmentName = value.equipmentName;
                this.formValidate1.type = value.type;
                this.formValidate1.purpose = value.purpose;
                this.formValidate1.amount = value.amount;
                this.formValidate1.accessoryTime = value.accessoryTime;
                this.equipmentManagement = true;
            },
            //删除
            compileSelectEq(selection, row) {   //表格选择
                var eqids = "";
                for (var i = 0; i < selection.length; i++) {
                    eqids = selection[i].id + "," + eqids;    //逗号分隔
                }
                this.eqidss = eqids;
            },
            deleEquipment(value) {  //单个删除
                this.eqidss = value;
                this.fireTruckInformation_removeByIdsForEquipment();
            },
            fireTruckInformation_removeByIdsForEquipment() { //删除车辆信息
                var _this = this;
                ezjsUtil.request(apiConstants.fireTruckInformation_removeByIdsForEquipment,
                    {
                        ids: _this.eqidss
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.fireTruckInformation_flipListForEquipment();
                    },
                )
            },
            //随车人员默认选中
            defaultChecked() {
                for(var k=0;k<this.personnelManagementDatas.length;k++){
                    for (var i = 0; i < this.personnelManagementTableDatas.length; i++) {
                        if(this.personnelManagementDatas[k].staffId==this.personnelManagementTableDatas[i].id){
                            this.personnelManagementTableDatas[i]._checked = true;
                        }
                    }
                }
            },
            /*添加选中随车人员*/
            diaojiekou() {
                var newids = this.staffIds.split(",");
                var idssplit = this.staffIds.split(",");
                for (var i = 0; i < idssplit.length; i++) {
                    for (var k = 0; k < this.personnelManagementDatas.length; k++) {
                        if (idssplit[i] == this.personnelManagementDatas[k].staffId) {
                            for (var n = 0; n < newids.length; n++) {
                                if (idssplit[i] == newids[n]) {
                                    newids.splice(n, 1);
                                }
                            }
                            break;
                        }
                    }
                }
                this.staffIds = newids.join(',');
                this.fireTruckInformation_editForCrew();
                this.personnelManagementData = false;
            },
            addPersonal() {
                this.staffManagement_flipList();
//                this.defaultChecked();
                this.personnelManagementData = true;
            },
            backPersonal() {
                this.personnelManagementData = false;
                this.currentPage3 = 1;
            },
            staffManagement_flipList() { //显示 查询
                var _this = this;
                ezjsUtil.request(apiConstants.staffManagement_flipList,
                    {
                        pageNo: _this.currentPage3
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.personnelManagementTableDatas = data.listInfo;
                        _this.totalCount3 = data.flipInfo.totalCount;
                        _this.defaultChecked();
                    }
                )
            },
            /*点击添加进来显示随车人员*/
            fireTruckInformation_flipListForCrew() { //显示 查询
                var _this = this;
                ezjsUtil.request(apiConstants.fireTruckInformation_flipListForCrew,
                    {
                        id: _this.carId,
//                        pageNo: _this.currentPage2,
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.personnelManagementDatas = data;
//                        _this.totalCount2 = data.flipInfo.totalCount;
                    }
                )
            },
            fireTruckInformation_editForCrew() { //新增随车人员
                var _this = this;
                ezjsUtil.request(apiConstants.fireTruckInformation_editForCrew,
                    {
                        staffIds: _this.staffIds,
                        id: _this.carId,
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.fireTruckInformation_flipListForCrew();
                    }
                )
            },
            /* JSON.stringify(jsonobj); //可以将json对象转换成json对符串 */
            surePersonal(selection) {
                var list = [];
                for (var i = 0; i < selection.length; i++) {
                    var node = selection[i];
                    list.push(node.id);
                }
                this.staffIds = list.join(',');

            },
            compileSelectPe(selection, row) {   //表格选择
                var eqi = "";
                for (var i = 0; i < selection.length; i++) {
                    eqi = selection[i].id + "," + eqi;    //逗号分隔
                }
                this.qeidss = eqi;
            },
            delePersonal(value) {  //单个删除
                this.qeidss = value;
                this.fireTruckInformation_removeByIdsForCrew();
            },
            fireTruckInformation_removeByIdsForCrew() { //删除车辆信息
                var _this = this;
                ezjsUtil.request(apiConstants.fireTruckInformation_removeByIdsForCrew,
                    {
                        ids: _this.qeidss
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.fireTruckInformation_flipListForCrew();
                    },
                )
            },
            /*组织机构数*/
            organization_flipList() { //显示 查询
                var _this = this;
                ezjsUtil.request(apiConstants.organization_flipList,
                    {},
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.baseData = data;
                        _this.baseData[0].expand=true;
                    }
                )
            },
            clickTree(value) {
              this.valueLen = value.length;
                    if (this.valueLen > 0 && this.departmentCode<=value[0].code) {
                            this.formValidate.departmentCode = value[0].code;
                            this.formValidate.departmentName = value[0].fullTitle;
                            this.formValidate.departmentNameCopy = value[0].fullTitle;
                            this.search_code=value[0].code;
                        }else {
                            this.formValidate.departmentCode = '';
                            this.formValidate.departmentName = '';
                            this.formValidate.departmentNameCopy = '';
                            this.search_code = '';
                        }
                    this.search();
            },
            /*字典数据相关接口*/
            dictionary_flipList() { //显示 查询
                var _this = this;
                ezjsUtil.request(apiConstants.dictionary_flipList,
                    {
                        key: "truckType",
                    },
                    function (err, data) {
                        if (err) {
                            return;
                        }
                        _this.truckTypeData = data;
                    }
                )
            },
        }
    }
</script>
<style lang="less" scoped>
    #fireManagement {
        height: 100%;
        overflow: auto;
        padding: 15px;

    .trees {
        width: 260px;
        height: 100%;
        padding-bottom: 30px;
        float: left;
        border: 1px solid #d3d8e0;
        overflow: auto;

    .tree_title {
        height: 40px;
        border-bottom: 1px solid #d3d8e0;

    .tree_title_h3 {
        line-height: 40px;
        text-align: center;
        font-size: 14px;
        color: #6e6d6d;
    }

    }
    .tree_body {
        padding-left: 8px;
    }

    }
    .body_right {
        margin-left: 280px;
        height: 100%;
        overflow: auto;

    .header-right {
        height: 40px;
        border-bottom: 1px solid #d3d8e0;
        font-size: 14px;
        color: #657180;
        line-height: 40px;
        font-family: '微软雅黑';
    }

    .btn_group {
        width: 100%;
        padding: 1.5rem 0;
    }

    .tableWidth {
        width: 100%;
    }

    }

    }
    .page_container {
        height: 30px;
        margin-top: 20px;

    .page_btn {
        float: right;
    }

    .page_text {
        float: right;
        line-height: 26px;
    }

    }
</style>
